package com.wkh.project.model.enums;

import lombok.Getter;

/**
 * @author wangkehua
 */

@Getter
public enum OrderStatus {
    // 订单状态及其描述和数字
    WAITING_FOR_ACCEPT(1, "等待接单"),
    ACCEPTED(2, "已接单"),
    DRIVER_ARRIVED(3, "司机已到达"),
    STARTED(4, "开始代驾"),
    FINISHED_DRIVING(5, "结束代驾"),
    UNPAID(6, "未付款"),
    PAID(7, "已付款"),
    ORDER_COMPLETED(8, "订单已结束"),
    CUSTOMER_CANCELLED(9, "顾客撤单"),
    DRIVER_CANCELLED(10, "司机撤单"),
    ACCIDENT_CLOSED(11, "事故关闭"),
    OTHER(12, "其他"),
    NULL_ORDER(-100, "不存在"),
    UPDATE_CART_INFO(4, "更新代驾车辆信息");

    // 获取枚举数字的getter方法
    // 枚举的属性
    private final int code;
    // 获取枚举描述的getter方法
    private final String description;

    // 枚举的构造方法（默认是private的）
    OrderStatus(int code, String description) {
        this.code = code;
        this.description = description;
    }

    // 根据数字查找枚举（可选）
    public static OrderStatus fromCode(int code) {  
        for (OrderStatus status : OrderStatus.values()) {  
            if (status.getCode() == code) {  
                return status;  
            }  
        }  
        throw new IllegalArgumentException("Unknown OrderStatus code: " + code);  
    }  
}